package com.baihan.angus.app.game.busshow.ui.user.setting;

import android.app.Application;

import androidx.annotation.NonNull;

import com.alibaba.android.arouter.launcher.ARouter;
import com.baihan.angus.app.game.basic.base.BaseResponse;
import com.baihan.angus.app.game.basic.base.view_model.BaseViewModel;
import com.baihan.angus.app.game.basic.utils.ActivityManager;
import com.baihan.angus.app.game.basic.utils.Tooast;
import com.baihan.angus.app.game.basic.utils.net.ApiObserver;
import com.baihan.angus.app.game.common.arouter_path.ArouterAppPath;
import com.baihan.angus.app.game.common.configs.UserConfig;
import com.baihan.angus.app.game.common.data_center.remote.RemoteDataMng;

public class SettingVM extends BaseViewModel {

    public SettingVM(@NonNull Application application) {
        super(application);
    }

    public void logout() {
        RemoteDataMng.getInstance().logout(mLifecycleProvider.bindToLifecycle(), new ApiObserver<BaseResponse>() {
            @Override
            public void onSuccess(BaseResponse baseResponse) {
                UserConfig.getUserConfig().clear();
                ActivityManager.getInstance().finishAllActivity();
                ARouter.getInstance().build(ArouterAppPath.LOGIN_ACTIVITY).navigation();
                finish();
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
            }
        });
    }
}
